﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
 namespace LinqTrain
 {  
     class Program
     {
         static void Main(string[] args)
         {
            List<int> infoList = new List<int>();
            for (int i = 0; i < 100; i++)
            {
                Random rd = new Random();
                infoList.Add(rd.Next(0, 1000));
            }
            
            // 使用LINQ和Lambda表达式排序
            List<int> orderedInfoList = infoList.OrderByDescending(s=>s).ToList<int>();
            // 输出
            //orderedInfoList.Reverse();
            int summ = infoList.Sum(s => s);
            double arv = infoList.Average(s => s);
            Console.WriteLine("排序结果为：");
            for(int i=0;i<100;i++)
            {
                Console.Write(orderedInfoList[i] + " ");
            }
            Console.WriteLine("\n和为" + summ + "\n平均数为" + arv);
            Console.ReadKey();
         }
     }
 }